#pragma once
#include "spa_types.h"
#include <vector>
#include "TNode.h"

typedef TNode TNODE;

struct RootNode{
	TNODE* node;
	PROCINDEX proc_index;
};

class AST{
private:
	vector<TNode*> tnode_store;
	vector<RootNode> rnode_store;
	map<INTEGER,TNODE*> stmt_to_tnode;
public:
	AST();
	~AST();
	TNODE* CreateNode(NODETYPE node_type);
	void CreateAST(TNODE* root_node, PROCINDEX proc_index);
	void SetValue(TNODE* this_node, STRING value);
	void SetStatementNumber(TNODE* this_node, INTEGER statement_number);
	void SetParentChildLink(TNODE* parent_node, TNODE* child_node, INTEGER nth_child);
	void SetRightSibling(TNODE* this_node, TNODE* right_node);
	TNODE* GetRoot(PROCINDEX proc_index);
	TNODE* GetChild(TNODE* parent_node, INTEGER nth_position);
	TNODE* GetRightSibling(TNODE* this_node);
	STRING GetValue(TNODE* this_node);
	NODETYPE GetNodeType(TNODE* this_node);
	INTEGER GetStatementNumber(TNODE* this_node);
	TNODE* GetNodeByStatementNumber(INTEGER statement_number);
};